/**
  * Copyright 2008 Frank van Lingen Licensed under the Apache 
  * License, Version 2.0 (the "License"); you may not use this file except in 
  * compliance with the License. You may obtain a copy of the License at 
  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
  * law or agreed to in writing, software distributed under the License is 
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
  * KIND, either express or implied. See the License for the specific language 
  * governing permissions and limitations under the License.
  */

package superpodder.gui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;

/**
 * A dialog class that provides some help information for the user and explains
 * the xml feed format used.
 * 
 * @author fvlingen
 */

public class LogView extends JDialog {

    private static final long serialVersionUID = -8351768253997601743L;
    
    public static JTextArea textArea = null;

    public LogView(JFrame parent) {
        super(parent, "Log", true);
        System.out.println("Starting Log Viewer");
        this.setMinimumSize(new Dimension(400, 200));
        this.setResizable(true);
        this.setSize(500, 400);

        // Allow to close but not exit the gui.
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                e.getWindow().setVisible(false);
            }
        });

        final GridBagLayout gridbag = new GridBagLayout();
        final GridBagConstraints gbc = new GridBagConstraints();

        this.setLayout(gridbag);
        
        // set external padding of components.
        gbc.insets = new Insets(2,2,2,2);
       
        gbc.weightx = 1;
        gbc.weighty = 1;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = GridBagConstraints.REMAINDER;
        gbc.fill = GridBagConstraints.BOTH;
       
        // Message this dialog displays.
        final String msg = "Logged failures and errors\n\n";
        textArea = new JTextArea(msg, 40, 50);
        Font font = new Font("Verdana", Font.BOLD, 12);
        textArea.setFont(font);
        textArea.setEditable(false);
        textArea.setEnabled(true);
        textArea.setLineWrap(true);

        final JScrollPane scrollPane = new JScrollPane(textArea,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        
        gridbag.setConstraints(scrollPane, gbc);
        this.add(scrollPane);

    }
}
